package com.qf.controller;

import com.netflix.discovery.converters.Auto;
import com.qf.pojo.reqVo.UserReq;
import com.qf.pojo.respVo.BaseResp;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/findAll",method = RequestMethod.GET)
    public BaseResp findAll(){
       return userService.findAll();
    }
    @RequestMapping(value = "saveOrUpdate",method = RequestMethod.POST)
    public BaseResp saveOrUpdate(@RequestBody UserReq userReq){
        return userService.saveOrUpdate(userReq);
    }
    @RequestMapping(value = "del",method = RequestMethod.DELETE)
    public BaseResp del(@RequestBody UserReq userReq){
        return userService.del(userReq.getUserId());
    }

    //获取email
    @RequestMapping("/getEmail")
    public BaseResp getEmail(@RequestParam("email")String email){
        return userService.getEmail(email);
    }
    @RequestMapping("/getUserName")
    public BaseResp loginName(@RequestBody UserReq userReq){
    return userService.userName(userReq);
    }

    @RequestMapping("/getCode")
    public BaseResp getCode(@RequestParam("email")String email){
    return userService.getCode(email);
    }

    @RequestMapping("/registry")
    public BaseResp registry(@RequestBody UserReq userReq){
        return userService.registry(userReq);
    }

    @RequestMapping("/login")
    public BaseResp login(@RequestBody UserReq userReq){
        return userService.login(userReq);
    }
}
